<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:common="http://java.sun.com/jsf/composite/components/common"
    template="/resources/templates/mainlayout.xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <div class = "form">
            <h:form id ="allowedRoles" styleClass = "niceform">
                <fieldset>
                    <legend>Allowed roles list</legend>
                    <h:dataTable value="#{adminJSFBean.allowedRoles}"
                                 binding="#{adminJSFBean.allowedRolesDataTable}"
                                 var = "role"
                                 border = "1" >
                        <h:column>
                            <f:facet name="header">
                                <f:verbatim>Rolename</f:verbatim>
                            </f:facet>
                            <h:outputText value="#{role.role}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <f:verbatim>Description</f:verbatim>
                            </f:facet>
                            <h:outputText value="#{role.description}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                            </f:facet>
                            <h:commandButton value="Usuń" action="#{adminJSFBean.removeAllowedRole}"/>
                        </h:column>
                    </h:dataTable>                
                </fieldset>
            </h:form>
            <h:form id ="newAllowedRole" styleClass = "niceform">
                <fieldset>
                    <legend>Add new allowed role</legend>
                    <ol>
                        <li>
                            <label for = "newAllowedRole:rolename">Role name (ID): </label>
                            <h:inputText id = "rolename" required = "true" value = "#{adminJSFBean.newAllowedRole.role}" />
                            <h:message for = "rolename" styleClass = "errorNotice" showDetail = "true" />
                        </li>
                        <li>
                            <label for = "newAllowedRole:description">Description: </label>
                            <h:inputTextarea id = "description" required = "false" value = "#{adminJSFBean.newAllowedRole.description}" />
                        </li>
                    </ol>
                </fieldset>
                <fieldset class = "control">
                    <h:commandButton action = "#{adminJSFBean.addNewAllowedRole}" value = "Add new allowed role"/>
                </fieldset>
            </h:form>
        </div>
    </ui:define>

</ui:composition>

